import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      name: "home",
      path: "/home",
      redirect: "/",
      component: () => import("@/views/homeView.vue"),
      children: [
        // 首页
        {
          path: "/",
          name: "homePage",
          component: () => import("@/views/homePage/index.vue"),
          meta: {
            title: "首页",
          },
        },
        // 搜索
        {
          path: "/search/:id?",
          name: "search",
          component: () => import("@/views/search/search.vue"),
          meta: {
            title: "搜索",
          },
        },
        //会员购买页面
        {
          path: "/memberPayment",
          name: "memberPayment",
          component: () => import("@/views/memberPayment/memberPayment.vue"),
          meta: {
            title: "会员购买",
          },
        },
        //会员协议
        {
          path: "/agreement",
          name: "agreement",
          component: () => import("@/views/agreement/agreement.vue"),
          meta: {
            title: "会员购买",
          },
        },
        // 市场洞察
        // 产品分析
        {
          path: "/productanalysis",
          name: "productanalysis",
          component: () => import("@/views/market/productanalysis.vue"),
          meta: {
            title: "产品分析",
          },
        },
        // 企业分析
        {
          path: "/companyanalysis",
          name: "companyanalysis",
          component: () => import("@/views/market/companyanalysis.vue"),
          meta: {
            title: "企业分析",
          },
        },
        // 医疗行业
        {
          path: "/medical",
          name: "medical",
          component: () => import("@/views/medical/medical.vue"),
          meta: {
            title: "医疗行业",
          },
        },

        // 数据服务
        // 数据导出平台
        {
          path: "/dataservice",
          name: "dataservice",
          component: () => import("@/views/dataService/dataservice.vue"),
          meta: {
            title: "数据导出平台",
          },
        },
        // 详情
        {
          path: "/details",
          name: "details",
          component: () => import("@/views/dataService/details.vue"),
          meta: {
            title: "搜索详情",
          },
        },

        // 数据开放平台
        {
          path: "/register",
          name: "register",
          component: () => import("@/views/dataService/register.vue"),
          meta: {
            title: "数据开放平台",
          },
        }, //标讯头条 最新标讯

        {
          path: "/doc",
          name: "doc",
          component: () => import("@/views/doc/doc.vue"),
          meta: {
            title: "数据开放平台",
          },
        }, //标讯头条 标讯精选
        {
          path: "/selected",
          name: "selected",
          component: () => import("@/views/doc/selected.vue"),
          meta: {
            title: "数据开放平台",
          },
        }, //标讯头条 标讯百科
        {
          path: "/wikipedia",
          name: "wikipedia",
          component: () => import("@/views/doc/wikipedia.vue"),
          meta: {
            title: "数据开放平台",
          },
        }, //标讯头条详情
        {
          path: "/article/:id",
          name: "article",
          component: () => import("@/views/article/article.vue"),
          meta: {
            title: "数据开放平台",
          },
        },

        // 搜索详情
        {
          path: "/searchInfo/:id/:nid?",
          name: "searchInfo",
          component: () => import("@/views/search/searchInfo.vue"),
          meta: {
            title: "搜索详情",
          },
        },
        // 供应商详情
        {
          path: "/disposition",
          name: "disposition",
          component: () => import("@/views/search/disposition/index.vue"),
          meta: {
            title: "供应商详情",
          },
        },
        // 1
        {
          path: "/webseo",
          name: "webseo",
          component: () => import("@/views/webseo/webseo.vue"),
          meta: {
            title: "1",
          },
        },
      ],
    },

    {
      path: "/a",
      name: "a",
      component: () => import("@/views/a.vue"),
    }, //会员支付页面
    {
      path: "/Payment",
      name: "Payment",
      component: () => import("@/views/Payment/Payment.vue"),
      meta: {
        title: "会员购买",
      },
    },
    {
      path: "/b",
      name: "b",
      component: () => import("@/views/b.vue"),
    },

    // 工作台新版
    {
      path: "/work",
      name: "work",
      component: () => import("@/views/work/work.vue"),
      children: [
        // 首页
        {
          path: "/header",
          name: "header",
          component: () => import("@/views/work/header/index.vue"),
          meta: {
            title: "首页",
          },
        },

        // 医械通
        {
          path: "/doctor",
          name: "doctor",
          component: () => import("@/views/work/doctor/index.vue"),
          meta: {
            title: "医械通",
          },
        },

        // 商机
        {
          path: "/business",
          name: "business",
          component: () => import("@/views/work/business/index.vue"),
          meta: {
            title: "商机",
          },
          children: [
            {
              path: "/movement",
              name: "movement",
              component: () => import("@/views/work/business/movement/index.vue"),
              meta: {
                title: "推送设置",
              },
            },
            {
              path: "/book",
              name: "book",
              component: () => import("@/views/work/business/book/index.vue"),
              meta: {
                title: "订阅设置",
              },
            },
            {
              path: "/opml",
              name: "opml",
              component: () => import("@/views/work/business/opml/index.vue"),
              meta: {
                title: "订阅列表",
              },
            },
            {
              path: "/collect",
              name: "collect",
              component: () => import("@/views/work/business/collect/index.vue"),
              meta: {
                title: "收藏列表",
              },
            },
          ]
        },

        //分析
        {
          path: "/analysis",
          name: "analysis",
          component: () => import("@/views/work/analysis/index.vue"),
          meta: {
            title: "分析",
          },
        },

        // 数据
        {
          path: "/data",
          name: "data",
          component: () => import("@/views/work/data/index.vue"),
          meta: {
            title: "数据",
          },
        },

        // 服务
        {
          path: "/give",
          name: "give",
          component: () => import("@/views/work/give/index.vue"),
          meta: {
            title: "服务",
          },
        },
        {
          path: "/integral",
          name: "integral",
          component: () => import("@/views/work/give/integral/index.vue"),
          meta: {
            title: "我的积分",
          },
        },

        {
          path: "/entry",
          name: "entry",
          component: () => import("@/views/work/give/entry/index.vue"),
          meta: {
            title: "发布列表",
          },
        },
        {
          path: "/News",
          name: "News",
          component: () => import("@/views/work/give/News/index.vue"),
          meta: {
            title: "信息发布",
          },
        },

        // 资产
        {
          path: "/means",
          name: "means",
          component: () => import("@/views/work/means/index.vue"),
          meta: {
            title: "资产",
          },
        },
        {
          path: "/Trafficpacket",
          name: "Trafficpacket",
          component: () => import("@/views/work/means/Trafficpacket/index.vue"),
          meta: {
            title: "兑换抵扣码",
          },
        },
        {
          path: "/exchange",
          name: "exchange",
          component: () => import("@/views/work/means/exchange/index.vue"),
          meta: {
            title: "数据流量包",
          },
        },
        {
          path: "/used",
          name: "used",
          component: () => import("@/views/work/means/used/index.vue"),
          meta: {
            title: "已用抵扣码",
          },
        },
        {
          path: "/scoreVip",
          name: "scoreVip",
          component: () => import("@/views/work/means/scoreVip/index.vue"),
          meta: {
            title: "会员购买记录",
          },
        },
        {
          path: "/annex",
          name: "annex",
          component: () => import("@/views/work/means/annex/index.vue"),
          meta: {
            title: "附件下载记录",
          },
        },

        // 设置
        {
          path: "/setup",
          name: "setup",
          component: () => import("@/views/work/setup/index.vue"),
          meta: {
            title: "设置",
          },
        },
        {
          path: "/identity",
          name: "identity",
          component: () => import("@/views/work/setup/identity/index.vue"),
          meta: {
            title: "身份信息维护",
          },
        },
        {
          path: "/account",
          name: "account",
          component: () => import("@/views/work/setup/account/index.vue"),
          meta: {
            title: "账号信息维护",
          },
        },
        {
          path: "/code",
          name: "code",
          component: () => import("@/views/work/setup/code/index.vue"),
          meta: {
            title: "修改密码",
          },
        },
      ],
    },

    // 工作台
    {
      path: "/staging",
      name: "staging",
      component: () => import("@/views/staging/staging.vue"),
      meta: {
        title: "工作台",
      },

      children: [
        // 首页
        {
          path: "/head",
          name: "head",
          component: () => import("@/views/staging/head/index.vue"),
          meta: {
            title: "首页",
          },
        },
        //设置
        {
          path: "/stagingSetup",
          name: "stagingSetup",
          component: () => import("@/views/staging/stagingSetup.vue"),
          meta: {
            title: "设置",
          },
          children: [
            //修改密码
            {
              path: "/stagingPassword",
              name: "stagingPassword",
              component: () => import("@/views/staging/stagingPassword.vue"),
              meta: {
                title: "修改密码",
              },
            },
            // 账号信息维护
            {
              path: "/stagingInfo",
              name: "stagingInfo",
              component: () => import("@/views/staging/stagingInfo.vue"),
              meta: {
                title: "账号信息维护",
              },
            },
            // 身份信息维护
            {
              path: "/stagingmaintenance",
              name: "stagingmaintenance",
              component: () => import("@/views/staging/stagingmaintenance.vue"),
              meta: {
                title: "身份信息维护",
              },
            },
          ],
        },
        // 订阅收藏
        {
          path: "/subscribe",
          name: "subscribe",
          component: () =>
            import("@/views/staging/SubscriptionService/subscribe.vue"),
          meta: {
            title: "订阅与收藏",
          },
          children: [
            //我的收藏
            {
              path: "/SubscriptionService/myfavorites",
              name: "myfavorites",
              component: () =>
                import(
                  "@/views/staging/SubscriptionService/computer/myfavorites/index.vue"
                ),
              meta: {
                title: "收藏列表",
              },
            },
            // 订阅列表
            {
              path: "/SubscriptionService/subscribeLiss",
              name: "subscribeLiss",
              component: () =>
                import(
                  "@/views/staging/SubscriptionService/computer/subscribeLiss/index.vue"
                ),
              meta: {
                title: "订阅列表",
              },
            },
            // 订阅设置
            {
              path: "/SubscriptionService/subscribe",
              name: "subscribe",
              component: () =>
                import(
                  "@/views/staging/SubscriptionService/computer/subscribe/index.vue"
                ),
              meta: {
                title: "订阅设置",
              },
            },
            // 推送设置
            {
              path: "/SubscriptionService/subscrinstall",
              name: "subscrinstall",
              component: () =>
                import(
                  "@/views/staging/SubscriptionService/computer/subscrinstall/index.vue"
                ),
              meta: {
                title: "推送设置",
              },
            },
          ],
        },
        // 服务
        {
          path: "/service",
          name: "service",
          component: () => import("@/views/staging/service/service.vue"),
          meta: {
            title: "服务",
          },
          children: [
            //信息发布
            {
              path: "/service/dissemination",
              name: "dissemination",
              component: () =>
                import(
                  "@/views/staging/service/computer/dissemination/index.vue"
                ),
              meta: {
                title: "信息发布",
              },
            },
            // 发布列表
            {
              path: "/service/publishing",
              name: "publishing",
              component: () =>
                import("@/views/staging/service/computer/publishing/index.vue"),
              meta: {
                title: "发布列表",
              },
            },
            // 我的积分
            {
              path: "/service/mypoints",
              name: "mypoints",
              component: () =>
                import("@/views/staging/service/computer/mypoints/index.vue"),
              meta: {
                title: "我的积分",
              },
            },
          ],
        },
        //操作记录
        {
          path: "/Myrecords",
          name: "Myrecords",
          component: () => import("@/views/staging/operate/Myrecords.vue"),
          meta: {
            title: "我的记录",
          },
          children: [
            //浏览记录
            {
              path: "/browse",
              name: "browse",
              component: () => import("@/views/staging/operate/browse.vue"),
              meta: {
                title: "浏览记录",
              },
            },
            // 处理记录
            {
              path: "/handle",
              name: "handle",
              component: () => import("@/views/staging/operate/handle.vue"),
              meta: {
                title: "处理记录",
              },
            },
            // 订单记录
            {
              path: "/order",
              name: "order",
              component: () => import("@/views/staging/operate/order.vue"),
              meta: {
                title: "订单记录",
              },
            },
          ],
        },
      ],
    },
  ],
});

// 路由守卫
// router.beforeEach((to, from, next) => {
//   const token = localStorage.getItem("token");
//   if (token) {
//     next("/");
//     console.log(token);
//   } else {
//   next("/login");
//   }
// });

export default router;
